﻿using System;
using System.Drawing;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.IO;
using System.Threading;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Net;
using System.Windows.Forms;
using System.Security;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Configuration;
using System.Runtime;
using dshow;
using System.Resources;
using dshow.Core;

namespace BrainTechLLC.WebCamLib3
{
    public static class DeviceInfoFactory
    {
        public static List<LocalVideoDevice> GetAvailableCaptureDevices(String szPreferredDevice)
        {
            List<LocalVideoDevice> rgDevices = new List<LocalVideoDevice>(8);
            FilterCollection filters;
            try
            {
                filters = new FilterCollection(FilterCategory.VideoInputDevice);

                for (int l = 0; l < filters.Count; l++)
                {
                    String szDeviceName = filters[l].Name;
                    String szMoniker = filters[l].MonikerString;
                    LocalVideoDevice vidDevice = new LocalVideoDevice(szDeviceName, szMoniker);
                    rgDevices.Add(vidDevice);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("GetAvailableCaptureDevices: " + ex.ToString());
                Debug.WriteLine("GetAvailableCaptureDevices: " + ex.Message);
            }

            return rgDevices;
        }        
    }
}
